<?php
class TicketsModel extends Db
{
    protected $_member_list = 'w_tickets_user'; //幸运用户
    /**
     * 添加幸运用户
     * Enter description here ...
     * @param unknown_type $params
     */
    public function addUser ($params)
    {
        $this->add($this->_member_list, $params);
    }
    public function saveUser ($v, $where)
    {
        return $this->update($this->_member_list, $v, $where);
    }
    public function sortByEmail ()
    {
        $sql = "select count(email) num,email from w_news_comment where nid=31678  group by email order by num DESC limit 5";
        return $this->fetchAll($sql);
    }
    public function sortByNickName ()
    {
        $sql = "select count(nick_name) num,nick_name,email from w_news_comment where nid=31678  group by nick_name order by num  DESC limit 5";
        return $this->fetchAll($sql);
    }
    public function sortByTheme ()
    {
        $sql = "select count(theme) num,theme from w_news_comment where nid=31678  group by theme order by num DESC limit 5";
        return $this->fetchAll($sql);
    }
    /**
     * 获取用户
     * Enter description here ...
     * @param unknown_type $where
     */
    public function findUserByWhere ($where)
    {
        return $this->getOne($this->_member_list, $where);
    }
    public function findUserAllByWHERE ($where)
    {
        return $this->getAll($this->_member_list, $where,'id,extend2');
    }
    
    /**
     * 最新输入用户
     * Enter description here ...
     * @param unknown_type $num
     */
    public function getLastOrder ($num)
    {
        $sql = "select * from w_news_comment where nid=31678 order by id desc limit $num";
        return $this->fetchAll($sql);
    }
    /**
     * 
     * 获取最新中奖用户
     */
    public function getLastUser ($num)
    {
        $sql = "SELECT * FROM $this->_member_list WHERE `type`>=1 ORDER BY id  DESC LIMIT $num";
        return $this->fetchAll($sql);
    }
    /**
     * 返回TicketsModel
     * @return TicketsModel
     */
    public static function instance ()
    {
        return self::_instance(__CLASS__);
    }
}